<?php
/**
 * Smarty plugin
 * -------------------------------------------------------------
 * File:     insert.module_page.php
 * Type:     time
 * Name:     time
 * Author:   王超, <wisoch@hotmail.com>
 * Purpose:  分页
 * -------------------------------------------------------------
 */

function smarty_insert_module_page($params, &$smarty) {
	$page = isset($params['page'])&& (int)$params['page'] > 0? (int)$params['page']: 1;
	$step = isset($params['step']) && is_numeric($params['count'])? (int)$params['step']: 5;
	$size = isset($params['size']) && is_numeric($params['size'])? (int)$params['size']: 20;
	$url = isset($params['url'])? $params['url']: '';
	$jump = isset($params['jump'])? (boolean)$params['jump']: true;
	$tpl = isset($params['tpl'])? $params['tpl']: 'module/module_page.html';
	$num = isset($params['num']) && is_numeric($params['num'])? $params['num']: 0;
	$query = isset($params['query'])? $params['query']: array();
	if(!$num) return '';
	
	$pager = new Page($num, $size, $page, $step, $query, $url);
	$smarty->assignByRef('pager', $pager);
	$smarty->assignByRef('jump', $jump);
	$html = $smarty->fetch($tpl);
	return $html;
}
?>